const baseUrl = 'http://150.158.18.181:8080';
const request = (url, data = {}, method = 'GET') => {
	uni.showLoading({
		title: '努力加载中...'
	})
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + url,
			method,
			data,
			success: (res) => {
				resolve(res.data);
			},
			fail: (err) => {
				uni.showToast({
					icon: 'error',
					title: '网络请求失败'
				})
				reject('网络请求失败');
			},
			complete: () => {
				uni.hideLoading();
			}
		})
	})
}
export const get = (url, data = {}) => {
	return request(url, data, 'GET');
}
export const post = (url, data = {}) => {
	return request(url, data, 'POST');
}